<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body,html{
            background-color: gray;
            width: 100%;
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: -10;
        }
        .box{
            position: relative;
            width: 150px;
            height: 50px;
            border-radius: 30px;
            overflow: hidden;
            z-index: -5;
           
        }
        .change{
            position: absolute;
            background-color: rgb(87, 10, 10);
            width: 150px;
            height: 50px;
            top: 0;
            left: 0px;
            border-radius: 30px;
            z-index: 1;
            transition: all 0.5s ease-in-out;
            box-shadow: 0 0 10px black inset;
            
        }
        .change::after{
            content: '';
            position: absolute;
            top: 50%;
            left: 0;
            border-radius: 50%;
            transform: translateY(-50%);
            width: 50px;
            height: 50px;
            box-shadow: 0 0 10px black;
            background-color: rgba(255, 255, 255, 0.356);
            transition: all 0.5s ease-in-out;
        }
        .btn{
            box-sizing: border-box;
            position: absolute;
            appearance: none;
            border: none;
            outline: none;
            width: 100%;
            height: 100%;
            z-index: 10;
        }
        .btn:checked+.change::after{
            left: 100px;
            
        }
        .btn:checked+.change{
            background-color: green;
            
        }
    </style>
</head>
<body>
    <div class="box">
        <input type="checkbox" class='btn'></input>
        <span class="change"></span>
    </div>
</body>
</html>